package newhiant.hianto2o.com.activity;

import android.databinding.DataBindingUtil;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import newhiant.hianto2o.com.BR;
import newhiant.hianto2o.com.R;
import newhiant.hianto2o.com.adapter.RVAdapter2;
import newhiant.hianto2o.com.databinding.ActivityRecyclerViewBinding;
import newhiant.hianto2o.com.model.Member;
import newhiant.hianto2o.com.utils.MyDecoration;

public class RecyclerViewActivity extends AppCompatActivity {

    private  RVAdapter2 mRVAdapter2;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_recycler_view);

        ActivityRecyclerViewBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_recycler_view);

        // 模拟数据
        List<Member> list = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            // 1个网络图片1个本地图片，依次循环
            Member member = new Member("user" + i, "https://test.hianto2o.com/data/upload/shop/store/goods/1019/2017/04/1019_05458295490018838_360.jpg" );
            list.add(member);

        }
//        Collections.reverse(list);

        // 设置布局管理器，及适配器
        binding.setRvLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));


        //第一种方案
        //        binding.setRvAdapter(new RvAdapter(this, list));



        //第二种方案
        binding.setMyDecoration(new MyDecoration(this,LinearLayoutManager.HORIZONTAL,5,android.R.color.holo_red_light));
//        binding.setMyDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));
        binding.setRvAdapter(new RVAdapter2(R.layout.item_recycler_activity, BR.member,this,list));


    }
}
